package com.crm.system.service.impl.customerManager;

import com.crm.common.model.DhPageInfo;
import com.crm.common.model.Enum.*;
import com.crm.common.util.CommonUtils;
import com.crm.model.entity.common.Dictionary;
import com.crm.model.entity.contactManager.Contact;
import com.crm.model.entity.contactManager.ContactInformation;
import com.crm.model.entity.customerManager.*;
import com.crm.model.entity.sys.UserAccount;
import com.crm.model.entity.sys.permissionManagement.SysCompany;
import com.crm.model.qo.customerManager.CustomerPoolAddQO;
import com.crm.model.qo.customerManager.CustomerPoolQO;
import com.crm.model.qo.customerManager.SendCodeQO;
import com.crm.model.vo.cluePoolManager.UserCompanyVO;
import com.crm.model.vo.contactManager.ContactInformationVO;
import com.crm.model.vo.customerManager.*;
import com.crm.service.common.DictionaryDbService;
import com.crm.service.contactManager.ContactDbService;
import com.crm.service.contactManager.ContactInformationDbService;
import com.crm.service.customerManager.CustomerContactPersonDbService;
import com.crm.service.customerManager.CustomerDbService;
import com.crm.service.customerManager.CustomerPoolDbService;
import com.crm.service.customerManager.CustomerSendCodeDbService;
import com.crm.service.returnMoney.FinishOrderDBservice;
import com.crm.system.service.contactManager.ContactInformationService;
import com.crm.system.service.customerManager.*;
import com.crm.system.service.permissionManagement.SysCompanyService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @ Author ：pym
 * @ Date   ：2021/1/15 10:10
 */
@Service
public class CustomerSendCodeServiceImpl implements CustomerSendCodeService {
    @Autowired
    CustomerSendCodeDbService customerSendCodeDbService;

    /**
     * 会员卡信息
     * @param pageIndex 页码
     * @param pageSize 条数
     * @param sortName 名称
     * @param sortOrder 排序
     * @param sendCodeQO 发码参数
     * @return
     */
    @Override
    public DhPageInfo<DetailMemberCardVO> customerProductDetailMemberCardList(Integer pageIndex, Integer pageSize, String sortName, String sortOrder, SendCodeQO sendCodeQO) {
        if (pageIndex != null && pageSize != null) {
            PageHelper.startPage(pageIndex, pageSize);
        }

        List<DetailMemberCardVO> list = customerSendCodeDbService.customerProductDetailMemberCardList(sendCodeQO);

        PageInfo<DetailMemberCardVO> pageInfo = new PageInfo<DetailMemberCardVO>(list);
        return new DhPageInfo<DetailMemberCardVO>(pageInfo, list);
    }

    /**
     * 税法直通车
     * @param pageIndex 页码
     * @param pageSize 条数
     * @param sortName 名称
     * @param sortOrder 排序
     * @param sendCodeQO 发码参数
     * @return
     */
    @Override
    public DhPageInfo<CustomerProductDetailThroughTrainTaxVO> customerProductDetailThroughTrainTaxList(Integer pageIndex, Integer pageSize, String sortName, String sortOrder, SendCodeQO sendCodeQO) {
        if (pageIndex != null && pageSize != null) {
            PageHelper.startPage(pageIndex, pageSize);
        }

        List<CustomerProductDetailThroughTrainTaxVO> list = customerSendCodeDbService.customerProductDetailThroughTrainTaxList(sendCodeQO);

        PageInfo<CustomerProductDetailThroughTrainTaxVO> pageInfo = new PageInfo<CustomerProductDetailThroughTrainTaxVO>(list);
        return new DhPageInfo<CustomerProductDetailThroughTrainTaxVO>(pageInfo, list);
    }

    /**
     * 兑换码信息
     * @param pageIndex 页码
     * @param pageSize 条数
     * @param sortName 名称
     * @param sortOrder 排序
     * @param sendCodeQO 发码参数
     * @return
     */
    @Override
    public DhPageInfo<CustomerProductDetailExchangeCodeVO> customerProductDetailExchangeCodeList(Integer pageIndex, Integer pageSize, String sortName, String sortOrder, SendCodeQO sendCodeQO) {
        if (pageIndex != null && pageSize != null) {
            PageHelper.startPage(pageIndex, pageSize);
        }

        List<CustomerProductDetailExchangeCodeVO> list = customerSendCodeDbService.customerProductDetailExchangeCodeList(sendCodeQO);

        PageInfo<CustomerProductDetailExchangeCodeVO> pageInfo = new PageInfo<CustomerProductDetailExchangeCodeVO>(list);
        return new DhPageInfo<CustomerProductDetailExchangeCodeVO>(pageInfo, list);
    }

    /**
     * 云顾问卡信息
     * @param pageIndex 页码
     * @param pageSize 条数
     * @param sortName 名称
     * @param sortOrder 排序
     * @param sendCodeQO 发码参数
     * @return
     */
    @Override
    public DhPageInfo<CustomerProductDetailYunVO> customerProductDetailYunList(Integer pageIndex, Integer pageSize, String sortName, String sortOrder, SendCodeQO sendCodeQO) {
        if (pageIndex != null && pageSize != null) {
            PageHelper.startPage(pageIndex, pageSize);
        }

        List<CustomerProductDetailYunVO> list = customerSendCodeDbService.customerProductDetailYunList(sendCodeQO);

        PageInfo<CustomerProductDetailYunVO> pageInfo = new PageInfo<CustomerProductDetailYunVO>(list);
        return new DhPageInfo<CustomerProductDetailYunVO>(pageInfo, list);
    }

    /**
     * 充值卡
     * @param pageIndex 页码
     * @param pageSize 条数
     * @param sortName 名称
     * @param sortOrder 排序
     * @param sendCodeQO 发码参数
     * @return
     */
    @Override
    public DhPageInfo<CustomerProductDetailRechargeCodeVO> customerProductDetailRechargeCodeList(Integer pageIndex, Integer pageSize, String sortName, String sortOrder, SendCodeQO sendCodeQO) {
        if (pageIndex != null && pageSize != null) {
            PageHelper.startPage(pageIndex, pageSize);
        }

        List<CustomerProductDetailRechargeCodeVO> list = customerSendCodeDbService.customerProductDetailRechargeCodeList(sendCodeQO);

        PageInfo<CustomerProductDetailRechargeCodeVO> pageInfo = new PageInfo<CustomerProductDetailRechargeCodeVO>(list);
        return new DhPageInfo<CustomerProductDetailRechargeCodeVO>(pageInfo, list);
    }

    /**
     * 优惠劵
     * @param pageIndex 页码
     * @param pageSize 条数
     * @param sortName 名称
     * @param sortOrder 排序
     * @param sendCodeQO 发码参数
     * @return
     */
    @Override
    public DhPageInfo<CustomerProductDetailCouponVO> customerProductDetailCouponList(Integer pageIndex, Integer pageSize, String sortName, String sortOrder, SendCodeQO sendCodeQO) {
        if (pageIndex != null && pageSize != null) {
            PageHelper.startPage(pageIndex, pageSize);
        }

        List<CustomerProductDetailCouponVO> list = customerSendCodeDbService.customerProductDetailCouponList(sendCodeQO);

        PageInfo<CustomerProductDetailCouponVO> pageInfo = new PageInfo<CustomerProductDetailCouponVO>(list);
        return new DhPageInfo<CustomerProductDetailCouponVO>(pageInfo, list);
    }
}
